import { basename } from 'node:path'
import { defineConfig } from 'vitepress'
import { La51Plugin } from 'vitepress-plugin-51la'
import MarkdownPreview from 'vite-plugin-markdown-preview'

import { head, nav, sidebar, algolia } from './configs'

const APP_BASE_PATH = basename(process.env.APP_BASE_PATH || '')

export default defineConfig({
  outDir: '../dist',
  base: APP_BASE_PATH ? `/${APP_BASE_PATH}/` : '/',

  lang: 'zh-CN',
  title: '零壹博客',  // 博客名称
  description: 'cm yan的Java后端成长之路，包含Java基础、框架学习、源码阅读、项目实战、开发工具等',  // 博客描述
  head,

  lastUpdated: true,
  cleanUrls: true,
  ignoreDeadLinks: 'localhostLinks',

  /* markdown 配置 */
  markdown: {
    lineNumbers: true,
    image: {
      lazyLoading: true,
    },
  },

  /* 主题配置 */
  themeConfig: {
    i18nRouting: false,

    logo: '/logo.png',

    nav,
    sidebar,

    /* 右侧大纲配置 */
    outline: {
      level: 'deep',
      label: '目录',
    },

    socialLinks: [{ icon: 'github', link: 'https://github.com/your-username' }],  // 修改为您的GitHub链接

    footer: {
      copyright: 'Copyright © 2024-present cm yan'  // 更新版权信息
    },

    lastUpdated: {
      text: '最后更新于',
      formatOptions: {
        dateStyle: 'short',
        timeStyle: 'medium',
      },
    },

    /* Algolia DocSearch 配置 */
    algolia,

    docFooter: {
      prev: '上一篇',
      next: '下一篇',
    },

    returnToTopLabel: '回到顶部',
    sidebarMenuLabel: '菜单',
    darkModeSwitchLabel: '主题',
    lightModeSwitchTitle: '切换到浅色模式',
    darkModeSwitchTitle: '切换到深色模式',

    /*** 自定义配置 ***/
    visitor: {
      badgeId: 'lingyi.notes',  // 访问量统计ID
    },

    comment: {
      repo: 'your-username/lingyi-notes',  // 修改为您的GitHub仓库
      repoId: 'YOUR_REPO_ID',  // 需要替换为Giscus生成的ID
      category: 'Announcements',
      categoryId: 'YOUR_CATEGORY_ID',  // 需要替换为Giscus生成的ID
    },
  },

  /* 生成站点地图 */
  sitemap: {
    hostname: 'https://your-domain.com/',  // 修改为您的实际域名
  },

  vite: {
    plugins: [MarkdownPreview(), La51Plugin({ id: '3LNfUkScYzEz6k4D', ck: '3LNfUkScYzEz6k4D' })],
    css: {
      preprocessorOptions: {
        scss: {
          api: 'modern-compiler',
        },
      },
    },
  },
})
